<%@ page language="java" pageEncoding="UTF-8"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean"%>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html"%>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic"%>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles"%>
<%
	String path = request.getContextPath();
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
<head>
	<html:base />

	<title>listRole.jsp</title>
	<link href="./css/xtab.css" rel="stylesheet" type="text/css" />


</head>

<body>
	<html:form action="/role.do">
		<html:hidden property="method" value="role.do?method=search" />

		 
		<table align="center" width="100%" cellspacing="0">
			<tr>

				<th class="tableTitle">
					角色名
				</th>
                <th class="tableTitle">
					描述
				</th>
				<th class="tableTitle">
					操作
				</th>

			</tr>
			<logic:iterate id="s" name="pageBean" property="list">
				<tr>
					<td class="tableElement">
						${s.roleName }
					</td>
					<td class="tableElement">
						${s.description }
					</td>
					 
					<td class="tableElement">
						<img src="<%=path%>/images/update.gif"
							onclick="updt('${s.roleId }')">
						<img src="<%=path%>/images/delete.gif"
							onclick="del('${s.roleId }')">
						<input type="button" class="button" value="授权" onclick="roleGrant('${s.roleId }');">
					</td>
				</tr>
			</logic:iterate>
		</table>
		 
		<br>
		<div align="center">
			<input type="button" id="toCreate" class="button" value="添加">
		</div>

		<script>
	$("#toCreate").click(function(){
		var f=document.forms[0];
		f.action="role.do?method=toCreateRole";
		f.submit();
	}); 
	updt=function(val){
	    var f=document.forms[0];
		f.action="role.do?method=toUpdateRole&id="+val;
		f.submit();
	}
	 
	del=function(val){
	    if(confirm("确定要删除吗?")){
		    var f=document.forms[0];
			f.action="role.do?method=delRole&id="+val;
			f.submit();
		}
	} 
	function roleGrant(roleId){
		var f=document.forms[0];
		f.action="role.do?method=toRoleGrant&id="+roleId;
		f.submit();
	}
	 
	</script>
	</html:form>
</body>
</html:html>
